import subprocess
import os

try:
    # test_pext.py
    print("PATHEXT =", os.environ.get('PATHEXT', 'NOT SET'))
    result = subprocess.run(['node', '--version'], capture_output=True, text=True, check=True)
    print("node version:", result.stdout.strip())
    result = subprocess.run(['npm.cmd', '--version'], capture_output=True, text=True, check=True)
    print("npm version:", result.stdout.strip())
except subprocess.CalledProcessError as e:
    print("命令执行失败:", e)
except FileNotFoundError:
    print("npm 未找到，请确认是否已安装并加入 PATH")